package lol.oxguy3.toaststrikesback;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.Toast;

public class ToastStrikesBackActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button enterbtn = new Button(this);//(Button) findViewById(R.id.buttonEnter);
        enterbtn.setText("Enter");
        enterbtn.setOnClickListener(new OnClickListener(){

			public void onClick(View v) {
				doEverything();
			}
        	
        });
        //this.
        ((TableLayout) findViewById(R.id.tableLayoutForm)).addView(enterbtn);//addContentView(enterbtn, null);
        
    }
    
    public void doEverything() {
    	String toasty = "Input received!\n";
    	
		toasty += "Name:\n\t";
		toasty += ((EditText) findViewById(R.id.editTextName)).getText().toString();
		toasty += "\n";
		
		toasty += "Address:\n\t";
		String address = ((EditText) findViewById(R.id.editTextAddress)).getText().toString();
		address = address.replaceAll("\n", "\n\t");
		toasty += address;
		
		
		Toast.makeText(getApplicationContext(), toasty, Toast.LENGTH_LONG).show();

    }
}